<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <style>
        *{
            margin: 0;
            padding: 0;
        }
        li{
            list-style: none;
        }
      /*  #box table {
            border-collapse: collapse;
        }*/
        table{
            border: 1px;
            width: 400px;
        }
        tr{
            background-color: #cccccc;
            height: 40px;
        }
    </style>
</head>
<body>
<div id="dv">
    <ul>
        <li>请输入姓名：<input type="text" value=""></li>
        <li>请输入邮箱：<input type="text" value=""></li>
        <li>请输入手机：<input type="text" value=""></li>
        <li>请输入地址：<input type="text" value=""></li>
    </ul>
    <button id="btn">添加</button>
</div>
<div id="box">
    <table>
        <thead>
         <tr>
            <th>姓名</th>
             <th>邮箱</th>
             <th>手机</th>
             <th>地址</th>
         </tr>
        </thead>
        <tbody id="tb">
        <tr>
            <td>小黑</td>
            <td>xiaohei@123.com</td>
            <td>12336654783</td>
            <td>北京</td>
        </tr>
        </tbody>
    </table>
</div>
<script>
    var btn=document.getElementById("btn");




    btn.onclick= function () {
        var flag=true;
        var inputs=document.getElementsByTagName("input");
        for (var i=0;i<inputs.length;i++){
            if (inputs[i].value.length==0){
                flag=false;
                break;
            }
        }
        if(flag){
            var tb=document.getElementById("tb");
            var tr=document.createElement("tr")
            tb.appendChild(tr)
            for(var i=0;i<inputs.length;i++){
                var td = document.createElement('td');
                tr.appendChild(td)
             td.innerHTML=inputs[i].value;
            }
            }else{
            alert("请输入完整内容")
        }

    }
</script>
</body>
</html>